using UniversalAdmin.Application.DTOs;

namespace UniversalAdmin.Application.Services;

public interface IRagService
{
    /// <summary>
    /// 基于用户查询获取相关文档
    /// </summary>
    /// <param name="userId">用户ID</param>
    /// <param name="query">查询内容</param>
    /// <param name="topK">返回的最大文档数量</param>
    /// <returns>相关文档列表</returns>
    Task<List<RelatedDocumentDto>> GetRelatedDocumentsAsync(Guid userId, string query, int topK = 5);

    /// <summary>
    /// 生成基于文档的回答
    /// </summary>
    /// <param name="userId">用户ID</param>
    /// <param name="query">查询内容</param>
    /// <param name="sessionId">会话ID</param>
    /// <param name="relatedDocuments">相关文档列表</param>
    /// <returns>生成的回答</returns>
    Task<string> GenerateAnswerAsync(Guid userId, string query, string sessionId, List<RelatedDocumentDto> relatedDocuments);

    /// <summary>
    /// 处理用户查询并生成回答
    /// </summary>
    /// <param name="userId">用户ID</param>
    /// <param name="query">查询内容</param>
    /// <param name="sessionId">会话ID</param>
    /// <returns>包含回答和相关文档的结果</returns>
    Task<ChatHistoryDto> ProcessQueryAsync(Guid userId, string query, string sessionId);

    /// <summary>
    /// 获取会话历史并生成上下文
    /// </summary>
    /// <param name="sessionId">会话ID</param>
    /// <param name="maxTokens">最大token数</param>
    /// <returns>会话上下文</returns>
    Task<string> GetSessionContextAsync(string sessionId, int maxTokens = 1000);
}